import React, { Component } from 'react'
import {Switch,Redirect,Route} from 'react-router-dom';
import Loadable from 'react-loadable';
/* 懒加载 */
/* 一级路由 */
var Home=Loadable({
    loader:()=>import('../components/Home/Home'),
    loading:()=><div className="div">加载中...</div>
})
var Order=Loadable({
    loader:()=>import('../components/Order/Order'),
    loading:()=><div className="div">加载中...</div>
})
var My=Loadable({
    loader:()=>import('../components/My/My'),
    loading:()=><div className="div">加载中...</div>
})
var Filter=Loadable({
    loader:()=>import('../components/Filter/Filter'),
    loading:()=><div className="div">加载中...</div>
})
var Detail=Loadable({
    loader:()=>import('../components/Detail/Detail'),
    loading:()=><div className="div">加载中...</div>
})
var Collent=Loadable({
    loader:()=>import('../components/Collent/Collent'),
    loading:()=><div className="div">加载中...</div>
})
var City=Loadable({
    loader:()=>import('../components/City/City'),
    loading:()=><div className="div">加载中...</div>
})
var AddCity=Loadable({
    loader:()=>import('../components/AddCity/AddCity'),
    loading:()=><div className="div">加载中...</div>
})
var Case=Loadable({
    loader:()=>import('../components/Case/Case'),
    loading:()=><div className="div">加载中...</div>
})
export default class Router extends Component {
    render() {
        return (
            /* 配置路由规则 */
            <Switch>
                <Route path='/home' component={Home}></Route>
                <Route path='/order' component={Order}></Route>
                <Route path='/my' component={My}></Route>
                <Route path='/filter' component={Filter}></Route>
                <Route path='/detail' component={Detail}></Route>
                <Route path='/collent' component={Collent}></Route>
                <Route path='/city' component={City}></Route>
                <Route path='/addcity' component={AddCity}></Route>
                <Route path='/case' component={Case}></Route>

                {/* 重定向 */}
                <Redirect to='/home'></Redirect>
            </Switch>
        )
    }
}
